<?php
namespace app\index\model\driver;
use think\Db;
use think\Model;

class Driver extends Model{
    protected $name = 'dd_publish';
    public function insert_data($data){
        if($data['type']==2){
            $status=Db::name('dd_publish')->where('type',2)->where('status',0)->where('uid',$data['uid'])->find();
            if ($status){
                return -2;//不可重复发布
            }else{
                $data["number"]=$data['number_info']["adult"]+$data['number_info']["children"]+$data['number_info']["infant"];
//            $data["insurance_price"]=$data['number_info']["cr"]+$data['number_info']["et"];
                $data['status']=0;
                $data['number_info']=json_encode($data['number_info']);
                $data['create_time']=time();
                return Db::name('dd_publish')->insertGetId($data);
            }
        }else{
            return -1;
        }


    }
}